<cfcomponent extends="Controller">
	<!--- [ Patient ] - List of Consumers --->
	<cffunction name="consumers">
		<cfscript>
			var recordCount = model("consumer").findAll(order="firstName, lastName").RecordCount;
			var columns = ["name", "name", "startDate", "endDate"];
			var orderBy = columns[PARAMS.iSortCol_1 + 1] & " " & PARAMS.sSortDir_1;
			var consumerList = Model("Consumer").findAll(order=orderBy);

			consumers = {
				"iTotalRecords" = recordCount,
				"iTotalDisplayRecords" = recordCount,
				"aaData" = []
			};

			for(intRow = 1; intRow LTE consumerList.RecordCount; intRow += 1) {
				if(UCase(Left(consumerList.firstName[intRow], 1)) IS "#PARAMS.sFilterLetter#") {
					ArrayAppend(consumers.aaData, {
						"DT_RowId" = consumerList.id[intRow],
						"0" = consumerList.name[intRow],
						"1" = ' ',
						"2" = DateFormat(consumerList.startDate[intRow], "mmm d, yyyy"),
						"3" = DateFormat(consumerList.endDate[intRow], "mmm d, yyyy")
					});
				}
			}

			Provides('json');
			RenderWith(consumers);
		</cfscript>
	</cffunction>
	
	<!--- [ Consumer ] - Profile --->
	<cffunction name="profile">
		<cfscript>
			User = Model("consumer").findByKey(PARAMS.key);
			ProfileName = "Consumer Profile :: " & User.firstName & " " & User.lastName;
			ArrayAppend(Get("Navigation").tabNames, ProfileName  );
		</cfscript>
	</cffunction>
	
	<!--- [ Patient ] - Profile | Records  --->
	<cffunction name="insurance">
		<cfscript>
			Insurance = Model("document").findAllByType(value="Insurance", order="sortOrder");
		</cfscript>
	</cffunction>
	
	<cffunction name="doctor">
		<cfscript>
			Doctor = Model("Document").findAllByType(value="Doctors", order="sortOrder");
		</cfscript>
	</cffunction>
	
	<cffunction name="assessment">
		<cfscript>
			Assessment = Model("Document").findAllByType(value= "Assessments", order="sortOrder");
		</cfscript>
	</cffunction>
	
	<!--- ITP/Progress Reports --->
	<cffunction name="itp">
		<cfscript>
			Documents = Model("Document").findAllByType(value="ITP", order="sortOrder");
		</cfscript>
	</cffunction>

	<cffunction name="medication">
		<cfscript>
			Medication = Model("Document").findAllByType(value="Medication", order="sortOrder");
		</cfscript>
	</cffunction>
	
	<cffunction name="discharge">
		<cfscript>
			Discharge = Model("Document").findAllByType(value="Discharge", order="sortOrder");
		</cfscript>
	</cffunction>
</cfcomponent>